package design.factory.factoryMethod;

public class HandGun implements Gun {
    private volatile int bulletC = 7;
    public HandGun() {
    }
    public HandGun(int c){
        this.bulletC = c;
    }
    @Override
    public void shoot() {
        for(;bulletC>0;) {
            System.out.println("嗒");
            synchronized (this) {
                bulletC--;
            }
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
